﻿@using Coralcode.Adapter.Gather.Entity.Enums
@using Coralcode.Adapter.Gather.Entity.Models
@using CoralNode.MvcClient.Helper

@model List<GatherCollectionModel>
@{
    ViewBag.Title = "采集结果集列表";
    ViewBag.Page = "gather";
}
@Html.IncludePage("CoralAdmin/gather", "_Left")
<!--content-->
<div id="pbody">
    <div class="extra">
        <div class="pbody_top">
            <span class="ico ico_import"></span><span class="t t_c">采集管理 /<b class="t_small f_no">采集结果集列表</b></span>
        </div>
        <div id="main" class="data_import_cnt">
            <div class="js_tabcnt">
                <div class="tablelist_style1" data-js="tabellist_style1">
                    <table cellpadding="0" cellspacing="0">
                            <tr class="exclude">
                                <th width="60">选择</th>
                                <th>名称</th>
                                <th>修改时间</th>
                                <th width="17%"> 导入状态</th>
                                <th>操作</th>
                            </tr>
                            @foreach (var item in Model)
                            {
                                <tr>
                                    <td>
                                        <label class="checkbox_own">
                                            <input name="checkboxid" type="checkbox" value="@item.HashCode" /></label>
                                    </td>
                                    <td>@item.Name</td>
                                    <td>@item.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
                                    <td>
                                        @if (ViewBag.GatherInfo.PrototypeId == 0)
                                        {
                                            @String.Format("未绑定导入目标")
                                        }
                                        else if(item.LastImportTime.HasValue)
                                        {
                                            @String.Format("{0}<br />成功{1}条 / 失败{2}条",item.LastImportTime.Value.ToString("yyyy/MM/dd HH:mm"),item.SuccessCount,item.FaildCount)
                                        }
                                        else
                                        {
                                            @String.Format("未导入")
                                        }
                                    </td>
                                    <td>
                                        @Html.ActionLink("查看", "gatherlist", new { gatherId = Request["gatherId"], collectionId = item.HashCode })
                                        @if (ViewBag.GatherInfo.PrototypeId>0){
                                            @Html.ActionLink("导入数据库", "transformationcollection", new { gatherId = Request["gatherId"], collectionIds = item.HashCode })
                                        }
                                    </td>
                                </tr>
                            }
                    </table>
                    <div class="global_fun ">
                        <label class="checkbox_own gloabal_select">
                            <input type="checkbox" /></label>
                        <input type="button" class="btn_4 btn invert" value="反选" /><input type="button" class="btn_4 btn reset"
                                                                                          value="重置" /><input type="button" class="btn_4 btn import" value="导入数据库" />
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $(".import").click(function () {
            if ($("[name='checkboxid']:checked").length == 0) {
                alert("没有选中待导入数据!");
                return;
            }
            var codes = new Array();
            $("[name='checkboxid']:checked").each(function () {
                codes.push($(this).val());
            });
            window.location = "@Url.Action("transformationcollection", new { gatherid = Request["gatherId"] })&collectionIds=" + codes.join();
        });
    });
</script>